package com.dj.xbirdie.viewmodels

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.dj.xbirdie.entity.MqttEntity

class MqttViewModel: ViewModel() {

    private val mName = MutableLiveData<String>()
    fun setName() {
        mName.value = "20"
    }

    fun getName(): LiveData<String>? {
        return mName
    }

    private val mqtt: MutableLiveData<MqttEntity> by lazy {
        MutableLiveData<MqttEntity>().also {
            MqttEntity();
        }
    }

    fun getMqttEntity(): LiveData<MqttEntity> {
        print("获取")
        return mqtt;
    }

    fun sync(){
        System.out.println(mqtt.value)
        Log.d("Viewmodel", "sync: ")
    }
    private fun loadMqttEnity(): MqttEntity {
        print("初始化viewmodel")
        return MqttEntity();
    }
}